package com.example.app.data.enum

import com.example.app.R

enum class AccountState(
    var label: String,
    var value: Any,
    var key: String
) {

    //收入还是支出
    INCOME(
        "收入",
        true,
        "INCOME"
    ),
    PAY(
        "支出",
        false,
        "PAY"
    ),
    //全部类型 , 搜索用
    ACCOUNT_TYPE_ALL(
        "全部类型",
        "全部类型",
        "ACCOUNT_TYPE_ALL"
    );

    companion object {
        fun getVarByLabel(label: String): AccountState? {
            values().forEach {
                if (label == it.label) return it
            }
            return null
        }

        fun getVarByValue(value: Any): AccountState? {
            values().forEach {
                if (value == it.value) return it
            }
            return null
        }

        fun getVarByKey(key: String): AccountState? {
            values().forEach {
                if (it.key == key) return it
            }
            return null
        }
    }
}